<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>⚡ 区块链资产管理 | Hyperledger Fabric</title>
    <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <style>
        :root {
            --primary: #00ff9d;
            --secondary: #00e1ff;
            --dark: #0a0a0a;
            --darker: #050505;
            --light: #f0f0f0;
            --gray: #2a2a2a;
            --card-bg: rgba(15, 15, 15, 0.7);
            --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
        }
        
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Roboto', sans-serif;
            background-color: var(--dark);
            color: var(--light);
            line-height: 1.6;
            overflow-x: hidden;
        }
        
        .container {
            max-width: 1400px;
            margin: 0 auto;
            padding: 20px;
        }
        
        /* 头部样式 */
        header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px 0;
            border-bottom: 1px solid var(--gray);
            margin-bottom: 30px;
        }
        
        .logo {
            display: flex;
            align-items: center;
            font-family: 'Orbitron', sans-serif;
            font-size: 24px;
            color: var(--primary);
        }
        
        .logo i {
            margin-right: 10px;
            font-size: 28px;
        }
        
        .theme-toggle {
            background: var(--gray);
            border: none;
            color: var(--light);
            width: 40px;
            height: 40px;
            border-radius: 50%;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: var(--transition);
        }
        
        .theme-toggle:hover {
            background: var(--primary);
            color: var(--dark);
        }
        
        /* 仪表板样式 */
        .dashboard {
            display: grid;
            grid-template-columns: 1fr 2fr;
            gap: 30px;
            margin-bottom: 30px;
        }
        
        .stats-card {
            background: var(--card-bg);
            border-radius: 10px;
            padding: 20px;
            backdrop-filter: blur(10px);
            border: 1px solid var(--gray);
            transition: var(--transition);
        }
        
        .stats-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 255, 157, 0.1);
        }
        
        .stats-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .stats-title {
            font-size: 16px;
            color: var(--secondary);
            font-weight: 300;
        }
        
        .stats-value {
            font-size: 36px;
            font-family: 'Orbitron', sans-serif;
            color: var(--primary);
            margin-bottom: 5px;
        }
        
        .stats-change {
            font-size: 14px;
            color: var(--light);
        }
        
        .positive {
            color: var(--primary);
        }
        
        /* 操作面板样式 */
        .action-panel {
            background: var(--card-bg);
            border-radius: 10px;
            padding: 25px;
            backdrop-filter: blur(10px);
            border: 1px solid var(--gray);
            margin-bottom: 30px;
        }
        
        .panel-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
            padding-bottom: 15px;
            border-bottom: 1px solid var(--gray);
        }
        
        .panel-title {
            font-size: 20px;
            font-weight: 700;
            color: var(--primary);
            font-family: 'Orbitron', sans-serif;
        }
        
        .tabs {
            display: flex;
            list-style: none;
        }
        
        .tab {
            padding: 8px 15px;
            margin-right: 10px;
            border-radius: 5px;
            cursor: pointer;
            font-size: 14px;
            transition: var(--transition);
        }
        
        .tab.active {
            background: var(--primary);
            color: var(--dark);
            font-weight: 700;
        }
        
        .tab:not(.active):hover {
            background: var(--gray);
        }
        
        .tab-content {
            display: none;
        }
        
        .tab-content.active {
            display: block;
            animation: fadeIn 0.5s ease-in-out;
        }
        
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        
        .form-group {
            margin-bottom: 20px;
        }
        
        .form-label {
            display: block;
            margin-bottom: 8px;
            font-size: 14px;
            color: var(--secondary);
        }
        
        .form-input {
            width: 100%;
            padding: 12px 15px;
            background: var(--darker);
            border: 1px solid var(--gray);
            border-radius: 5px;
            color: var(--light);
            font-size: 14px;
            transition: var(--transition);
        }
        
        .form-input:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 2px rgba(0, 255, 157, 0.2);
        }
        
        .btn {
            padding: 12px 25px;
            border-radius: 5px;
            border: none;
            font-weight: 700;
            cursor: pointer;
            transition: var(--transition);
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        
        .btn-primary {
            background: var(--primary);
            color: var(--dark);
        }
        
        .btn-primary:hover {
            background: #00e68a;
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 255, 157, 0.3);
        }
        
        .btn i {
            margin-right: 8px;
        }
        
        /* 资产列表样式 */
        .assets-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
            gap: 20px;
            margin-top: 20px;
        }
        
        .asset-card {
            background: var(--card-bg);
            border-radius: 10px;
            padding: 20px;
            border: 1px solid var(--gray);
            transition: var(--transition);
            position: relative;
            overflow: hidden;
        }
        
        .asset-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0, 255, 157, 0.1);
            border-color: var(--primary);
        }
        
        .asset-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            width: 3px;
            height: 100%;
            background: var(--primary);
        }
        
        .asset-id {
            font-family: 'Orbitron', sans-serif;
            color: var(--primary);
            font-size: 14px;
            margin-bottom: 5px;
        }
        
        .asset-name {
            font-size: 18px;
            font-weight: 700;
            margin-bottom: 10px;
        }
        
        .asset-owner {
            display: flex;
            align-items: center;
            font-size: 14px;
            color: var(--secondary);
            margin-bottom: 15px;
        }
        
        .asset-owner i {
            margin-right: 8px;
        }
        
        .asset-info {
            font-size: 14px;
            line-height: 1.5;
            color: #aaa;
            margin-bottom: 15px;
        }
        
        .asset-actions {
            display: flex;
            justify-content: space-between;
        }
        
        .asset-btn {
            padding: 8px 12px;
            font-size: 12px;
            border-radius: 4px;
            background: var(--gray);
            color: var(--light);
            border: none;
            cursor: pointer;
            transition: var(--transition);
            display: flex;
            align-items: center;
        }
        
        .asset-btn i {
            margin-right: 5px;
        }
        
        .asset-btn:hover {
            background: var(--primary);
            color: var(--dark);
        }
        
        /* 交易历史样式 */
        .transactions {
            margin-top: 30px;
        }
        
        .transaction-item {
            display: flex;
            justify-content: space-between;
            padding: 15px;
            border-bottom: 1px solid var(--gray);
            transition: var(--transition);
        }
        
        .transaction-item:hover {
            background: rgba(0, 255, 157, 0.05);
        }
        
        .transaction-id {
            font-family: 'Orbitron', sans-serif;
            color: var(--primary);
            font-size: 12px;
            width: 150px;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        
        .transaction-details {
            flex: 1;
            padding: 0 20px;
        }
        
        .transaction-type {
            font-weight: 700;
            margin-bottom: 5px;
        }
        
        .transaction-asset {
            font-size: 12px;
            color: #aaa;
        }
        
        .transaction-time {
            font-size: 12px;
            color: var(--secondary);
            text-align: right;
        }
        
        /* 响应式设计 */
        @media (max-width: 992px) {
            .dashboard {
                grid-template-columns: 1fr;
            }
        }
        
        @media (max-width: 768px) {
            .assets-grid {
                grid-template-columns: 1fr;
            }
            
            .transaction-item {
                flex-direction: column;
            }
            
            .transaction-id {
                width: 100%;
                margin-bottom: 10px;
            }
            
            .transaction-details {
                padding: 0;
                margin-bottom: 10px;
            }
            
            .transaction-time {
                text-align: left;
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <div class="logo">
                <i class="fas fa-link"></i>
                <span>ChainAssets</span>
            </div>
            <button class="theme-toggle" id="themeToggle">
                <i class="fas fa-moon"></i>
            </button>
        </header>
        
        <div class="dashboard">
            <div class="stats-card">
                <div class="stats-header">
                    <div class="stats-title">总资产</div>
                    <i class="fas fa-box-open" style="color: var(--primary);"></i>
                </div>
                <div class="stats-value" id="totalAssets">0</div>
                <div class="stats-change positive">
                    <i class="fas fa-arrow-up"></i> 12% 过去7天
                </div>
            </div>
            
            <div class="stats-card">
                <div class="stats-header">
                    <div class="stats-title">交易数量</div>
                    <i class="fas fa-exchange-alt" style="color: var(--secondary);"></i>
                </div>
                <div class="stats-value" id="totalTransactions">0</div>
                <div class="stats-change positive">
                    <i class="fas fa-arrow-up"></i> 8% 过去7天
                </div>
            </div>
        </div>
        
        <div class="action-panel">
            <div class="panel-header">
                <h2 class="panel-title">资产管理</h2>
                <ul class="tabs" id="actionTabs">
                    <li class="tab active" data-tab="create">创建资产</li>
                    <li class="tab" data-tab="query">查询资产</li>
                    <li class="tab" data-tab="transfer">转移资产</li>
                </ul>
            </div>
            
            <div class="tab-content active" id="create">
                <div class="form-group">
                    <label class="form-label">资产ID</label>
                    <input type="text" class="form-input" id="create-id" placeholder="输入唯一资产ID">
                </div>
                <div class="form-group">
                    <label class="form-label">所有者</label>
                    <input type="text" class="form-input" id="create-owner" placeholder="输入所有者名称">
                </div>
                <div class="form-group">
                    <label class="form-label">资产名称</label>
                    <input type="text" class="form-input" id="create-name" placeholder="输入资产名称">
                </div>
                <div class="form-group">
                    <label class="form-label">资产信息</label>
                    <input type="text" class="form-input" id="create-info" placeholder="输入资产描述信息">
                </div>
                <button class="btn btn-primary" onclick="createAsset()">
                    <i class="fas fa-plus"></i> 创建资产
                </button>
            </div>
            
            <div class="tab-content" id="query">
                <div class="form-group">
                    <label class="form-label">资产ID</label>
                    <input type="text" class="form-input" id="query-id" placeholder="输入要查询的资产ID">
                </div>
                <button class="btn btn-primary" onclick="queryAsset()">
                    <i class="fas fa-search"></i> 查询资产
                </button>
                <div id="query-result" style="margin-top: 20px;"></div>
            </div>
            
            <div class="tab-content" id="transfer">
                <div class="form-group">
                    <label class="form-label">资产ID</label>
                    <input type="text" class="form-input" id="transfer-id" placeholder="输入要转移的资产ID">
                </div>
                <div class="form-group">
                    <label class="form-label">新所有者</label>
                    <input type="text" class="form-input" id="new-owner" placeholder="输入新的所有者名称">
                </div>
                <button class="btn btn-primary" onclick="transferAsset()">
                    <i class="fas fa-exchange-alt"></i> 转移所有权
                </button>
                <div id="transfer-result" style="margin-top: 20px;"></div>
            </div>
        </div>
        
        <div class="panel-header">
            <h2 class="panel-title">资产列表</h2>
            <button class="btn btn-primary" onclick="getAllAssets()">
                <i class="fas fa-sync-alt"></i> 刷新列表
            </button>
        </div>
        
        <div class="assets-grid" id="all-assets">
            <!-- 资产卡片将通过JavaScript动态加载 -->
        </div>
        
        <div class="panel-header" style="margin-top: 40px;">
            <h2 class="panel-title">最近交易</h2>
        </div>
        
        <div class="transactions" id="recent-transactions">
            <!-- 交易记录将通过JavaScript动态加载 -->
        </div>
    </div>

    <script>
        // 主题切换功能
        const themeToggle = document.getElementById('themeToggle');
        let darkMode = true;
        
        themeToggle.addEventListener('click', () => {
            darkMode = !darkMode;
            document.body.style.backgroundColor = darkMode ? '#0a0a0a' : '#f5f5f5';
            document.body.style.color = darkMode ? '#f0f0f0' : '#333';
            themeToggle.innerHTML = darkMode ? '<i class="fas fa-moon"></i>' : '<i class="fas fa-sun"></i>';
            
            // 这里可以添加更多的主题切换逻辑
        });
        
        // 标签页切换功能
        const tabs = document.querySelectorAll('.tab');
        tabs.forEach(tab => {
            tab.addEventListener('click', () => {
                // 移除所有active类
                tabs.forEach(t => t.classList.remove('active'));
                document.querySelectorAll('.tab-content').forEach(c => c.classList.remove('active'));
                
                // 添加active类到当前标签
                tab.classList.add('active');
                document.getElementById(tab.dataset.tab).classList.add('active');
            });
        });
        
        // 模拟数据
        const mockAssets = [
            { id: "AST-2023-001", owner: "Alice", name: "量子服务器", info: "高性能量子计算服务器，用于AI训练", txCount: 3 },
            { id: "AST-2023-002", owner: "Bob", name: "区块链节点", info: "企业级区块链全节点服务器", txCount: 5 },
            { id: "AST-2023-003", owner: "Charlie", name: "数据中心", info: "位于硅谷的Tier4数据中心", txCount: 2 },
            { id: "AST-2023-004", owner: "Alice", name: "加密矿机", info: "新一代SHA-256加密矿机", txCount: 7 },
            { id: "AST-2023-005", owner: "Dave", name: "网络设备", info: "企业级路由器和交换机", txCount: 1 },
            { id: "AST-2023-006", owner: "Eve", name: "存储阵列", info: "PB级分布式存储系统", txCount: 4 }
        ];
        
        const mockTransactions = [
            { id: "TX-001", type: "CREATE", asset: "AST-2023-001", time: "2023-05-15 14:30" },
            { id: "TX-002", type: "TRANSFER", asset: "AST-2023-002", time: "2023-05-15 15:45" },
            { id: "TX-003", type: "CREATE", asset: "AST-2023-003", time: "2023-05-16 09:20" },
            { id: "TX-004", type: "TRANSFER", asset: "AST-2023-001", time: "2023-05-16 11:15" },
            { id: "TX-005", type: "CREATE", asset: "AST-2023-004", time: "2023-05-17 16:30" }
        ];
        
        // 更新统计信息
        function updateStats() {
            document.getElementById('totalAssets').textContent = mockAssets.length;
            document.getElementById('totalTransactions').textContent = mockTransactions.length;
        }
        
        // 创建资产
        function createAsset() {
            const id = document.getElementById('create-id').value;
            const owner = document.getElementById('create-owner').value;
            const name = document.getElementById('create-name').value;
            const info = document.getElementById('create-info').value;
            
            if (!id || !owner || !name) {
                alert('请填写所有必填字段！');
                return;
            }
            
            // 模拟API调用
            setTimeout(() => {
                // 添加到模拟数据
                mockAssets.unshift({
                    id, owner, name, info, txCount: 1
                });
                
                mockTransactions.unshift({
                    id: `TX-${Math.random().toString(36).substr(2, 8).toUpperCase()}`,
                    type: "CREATE",
                    asset: id,
                    time: new Date().toISOString().replace('T', ' ').substr(0, 16)
                });
                
                // 更新UI
                updateStats();
                renderAssets();
                renderTransactions();
                
                // 显示成功消息
                const resultDiv = document.createElement('div');
                resultDiv.innerHTML = `
                    <div style="background: rgba(0, 255, 157, 0.2); padding: 10px; border-radius: 5px; margin-top: 15px; border-left: 3px solid var(--primary);">
                        <i class="fas fa-check-circle" style="color: var(--primary); margin-right: 8px;"></i>
                        <strong>资产创建成功！</strong> 资产ID: ${id}
                    </div>
                `;
                document.getElementById('create').appendChild(resultDiv);
                
                // 清空表单
                document.getElementById('create-id').value = '';
                document.getElementById('create-owner').value = '';
                document.getElementById('create-name').value = '';
                document.getElementById('create-info').value = '';
                
                // 3秒后移除消息
                setTimeout(() => resultDiv.remove(), 3000);
            }, 800);
        }
        
        // 查询资产
        function queryAsset() {
            const id = document.getElementById('query-id').value;
            
            if (!id) {
                alert('请输入资产ID！');
                return;
            }
            
            // 模拟API调用
            setTimeout(() => {
                const asset = mockAssets.find(a => a.id === id);
                const resultDiv = document.getElementById('query-result');
                
                if (asset) {
                    resultDiv.innerHTML = `
                        <div style="background: var(--card-bg); padding: 15px; border-radius: 5px; border-left: 3px solid var(--primary);">
                            <div style="display: flex; justify-content: space-between; margin-bottom: 10px;">
                                <h3 style="color: var(--primary); margin: 0;">${asset.name}</h3>
                                <span style="font-family: 'Orbitron', sans-serif; font-size: 12px; color: var(--secondary);">${asset.id}</span>
                            </div>
                            <div style="display: flex; align-items: center; margin-bottom: 10px;">
                                <i class="fas fa-user" style="color: var(--secondary); margin-right: 8px;"></i>
                                <span>所有者: ${asset.owner}</span>
                            </div>
                            <div style="margin-bottom: 10px;">
                                <p style="margin: 0; color: #aaa;">${asset.info}</p>
                            </div>
                            <div style="font-size: 12px; color: var(--secondary);">
                                <i class="fas fa-exchange-alt" style="margin-right: 5px;"></i>
                                交易次数: ${asset.txCount}
                            </div>
                        </div>
                    `;
                } else {
                    resultDiv.innerHTML = `
                        <div style="background: rgba(255, 80, 80, 0.2); padding: 10px; border-radius: 5px; border-left: 3px solid #ff5050;">
                            <i class="fas fa-exclamation-circle" style="color: #ff5050; margin-right: 8px;"></i>
                            <strong>未找到资产！</strong> 没有找到ID为 ${id} 的资产
                        </div>
                    `;
                }
            }, 600);
        }
        
        // 转移资产
        function transferAsset() {
            const id = document.getElementById('transfer-id').value;
            const newOwner = document.getElementById('new-owner').value;
            
            if (!id || !newOwner) {
                alert('请输入资产ID和新所有者！');
                return;
            }
            
            // 模拟API调用
            setTimeout(() => {
                const assetIndex = mockAssets.findIndex(a => a.id === id);
                const resultDiv = document.getElementById('transfer-result');
                
                if (assetIndex !== -1) {
                    const oldOwner = mockAssets[assetIndex].owner;
                    mockAssets[assetIndex].owner = newOwner;
                    mockAssets[assetIndex].txCount += 1;
                    
                    mockTransactions.unshift({
                        id: `TX-${Math.random().toString(36).substr(2, 8).toUpperCase()}`,
                        type: "TRANSFER",
                        asset: id,
                        time: new Date().toISOString().replace('T', ' ').substr(0, 16)
                    });
                    
                    // 更新UI
                    renderAssets();
                    renderTransactions();
                    
                    resultDiv.innerHTML = `
                        <div style="background: rgba(0, 255, 157, 0.2); padding: 10px; border-radius: 5px; border-left: 3px solid var(--primary);">
                            <i class="fas fa-check-circle" style="color: var(--primary); margin-right: 8px;"></i>
                            <strong>资产转移成功！</strong> 资产 ${id} 已从 ${oldOwner} 转移到 ${newOwner}
                        </div>
                    `;
                    
                    // 清空表单
                    document.getElementById('transfer-id').value = '';
                    document.getElementById('new-owner').value = '';
                } else {
                    resultDiv.innerHTML = `
                        <div style="background: rgba(255, 80, 80, 0.2); padding: 10px; border-radius: 5px; border-left: 3px solid #ff5050;">
                            <i class="fas fa-exclamation-circle" style="color: #ff5050; margin-right: 8px;"></i>
                            <strong>未找到资产！</strong> 没有找到ID为 ${id} 的资产
                        </div>
                    `;
                }
            }, 800);
        }
        
        // 渲染资产列表
        function renderAssets() {
            const container = document.getElementById('all-assets');
            container.innerHTML = '';
            
            mockAssets.forEach(asset => {
                const card = document.createElement('div');
                card.className = 'asset-card';
                card.innerHTML = `
                    <div class="asset-id">${asset.id}</div>
                    <h3 class="asset-name">${asset.name}</h3>
                    <div class="asset-owner">
                        <i class="fas fa-user"></i>
                        ${asset.owner}
                    </div>
                    <p class="asset-info">${asset.info}</p>
                    <div class="asset-actions">
                        <button class="asset-btn" onclick="showAssetDetails('${asset.id}')">
                            <i class="fas fa-eye"></i> 查看
                        </button>
                        <button class="asset-btn" onclick="prepareTransfer('${asset.id}')">
                            <i class="fas fa-exchange-alt"></i> 转移
                        </button>
                    </div>
                `;
                container.appendChild(card);
            });
        }
        
        // 渲染交易记录
        function renderTransactions() {
            const container = document.getElementById('recent-transactions');
            container.innerHTML = '';
            
            mockTransactions.slice(0, 5).forEach(tx => {
                const item = document.createElement('div');
                item.className = 'transaction-item';
                item.innerHTML = `
                    <div class="transaction-id">${tx.id}</div>
                    <div class="transaction-details">
                        <div class="transaction-type">${tx.type === 'CREATE' ? '创建资产' : '转移所有权'}</div>
                        <div class="transaction-asset">资产: ${tx.asset}</div>
                    </div>
                    <div class="transaction-time">${tx.time}</div>
                `;
                container.appendChild(item);
            });
        }
        
        // 辅助函数 - 显示资产详情
        function showAssetDetails(id) {
            document.getElementById('query-id').value = id;
            document.querySelector('.tab[data-tab="query"]').click();
            queryAsset();
        }
        
        // 辅助函数 - 准备转移资产
        function prepareTransfer(id) {
            document.getElementById('transfer-id').value = id;
            document.querySelector('.tab[data-tab="transfer"]').click();
        }
        
        // 获取所有资产
        function getAllAssets() {
            // 模拟加载动画
            const container = document.getElementById('all-assets');
            container.innerHTML = '<div style="grid-column: 1 / -1; text-align: center; padding: 30px; color: var(--secondary);"><i class="fas fa-spinner fa-spin"></i> 加载中...</div>';
            
            setTimeout(() => {
                renderAssets();
                
                // 显示刷新成功消息
                const message = document.createElement('div');
                message.innerHTML = `
                    <div style="grid-column: 1 / -1; background: rgba(0, 255, 157, 0.2); padding: 10px; border-radius: 5px; margin-bottom: 15px; border-left: 3px solid var(--primary); text-align: center;">
                        <i class="fas fa-check-circle" style="color: var(--primary); margin-right: 8px;"></i>
                        资产列表已刷新
                    </div>
                `;
                container.prepend(message);
                
                setTimeout(() => message.remove(), 2000);
            }, 1000);
        }
        
        // 初始化
        updateStats();
        renderAssets();
        renderTransactions();
    </script>
</body>
</html>